<template>
  <div>
      <h1>登录日志</h1>
      <el-table :data="paginatedStudents"  style="width: 80%">
      <el-table-column prop="studentId" label="学号" />
      <el-table-column prop="name" label="姓名" />
      <el-table-column prop="loginTime" label="登录时间" />
    </el-table>
       <el-pagination
  background
  layout="prev, pager, next"
  :total="totalCount"
  @current-change="handleCurrentChange">
</el-pagination>
  </div>
</template>

<script>
import axios from 'axios';

export default {
  name: 'loginlog',
  data() {
      return {
          students: [], 
          currentPage: 1,
          pageSize: 10,
          totalCount: 0,
          paginatedStudents: []
      };
  },
  created() {
      this.fetchStudents();
  },
  methods: {
    handleCurrentChange(val){
        this.currentPage=val;
        this.fetchStudents();
    },
      fetchStudents() {
        axios.get(`api/cource/loginlognum`)
              .then(response => {
                this.totalCount = response.data.data;
                //  let t=response.data.data%10
                // //  console.log(t)
                //  if(t==0){
                //   this.totalCount=response.data.data/10;
                //  }else{
                //    this.totalCount= Math.floor(response.data.data / 10) + 1;
                //    console.log(this.totalCount)
                //  }
              }).catch(error => {
                  console.error(error);
              });
          axios.get(`api/cource/loginlog?page=${this.currentPage}&pageSize=${this.pageSize}`)
              .then(response => {
                  this.paginatedStudents = response.data.data;
              }).catch(error => {
                  console.error(error);
              });
      },
  }
};
</script>

<style>
/* CSS样式 */
</style>